import 'package:library_base/net/apis.dart';
import 'package:library_base/network/http_config.dart';
import 'package:library_base/provider/base_controller.dart';
import 'package:get/get.dart';
import 'package:library_base/entities/dashboard_entity.dart';

class WmsWorkbenchController extends BaseController {

  Rxn<DashboardEntity?> workbenchEntity = Rxn<DashboardEntity?>();

  String get purchaseCount =>
      workbenchEntity.value == null || workbenchEntity.value!.waitingStockInCount == "0"
          ? '--'
          : workbenchEntity.value!.waitingStockInCount.toString();

  String get inquiredCount =>
      workbenchEntity.value == null || workbenchEntity.value!.waitingStockOutCount == "0"
          ? '--'
          : workbenchEntity.value!.waitingStockOutCount.toString();

  @override
  Future requestData() {
    workbench();
    return super.requestData();
  }

  workbench() {
    if (baseState!.mounted) {
      requestUniversal<DashboardEntity>(Apis.DASHBOARD,
          isSendShowDialog: false, method: FBResultFul.GET, resultSuccessCall: (data) {
        workbenchEntity.value = data;
        update();
      });
    }
  }

  @override
  void onResume() {
    super.onResume();
    workbench();
  }
}
